﻿using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using Holoville.HOTween;

public partial class FriendScene : Scene
{
	public string DatetimeToString(long dateGap)
	{
		DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
		DateTime targetDate = startDate.AddMilliseconds(dateGap).ToLocalTime();
		return targetDate.Year.ToString();
	}

	public string DatetimeToFomattedString(long dateGap)
	{
		DateTime nowDate = DateTime.Now;

		DateTime startDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
		DateTime targetDate = startDate.AddMilliseconds(dateGap).ToLocalTime();

		TimeSpan ts = nowDate - targetDate;

		if (ts.Days >= 60)
		{
			return Localization.Get("uiFriendTimeTypeD");
		}
		else if (ts.Days >= 1)
		{
			return string.Format(Localization.Get("uiFriendTimeTypeA"), ts.Days.ToString());
			//return string.Format("[AAAAFF]" + Localization.Get("uiFriendTimeTypeA"), ts.Days.ToString());
		}
		else if (ts.Hours > 0)
		{
			return string.Format(Localization.Get("uiFriendTimeTypeB"), ts.Hours.ToString(), ts.Minutes.ToString());
			//return string.Format("[AAAAFF]" + Localization.Get("uiFriendTimeTypeB"), ts.Hours.ToString(), ts.Minutes.ToString());
		}
		else
		{
			return string.Format(Localization.Get("uiFriendTimeTypeC"), ts.Minutes.ToString());
			//return string.Format("[AAAAFF]" + Localization.Get("uiFriendTimeTypeC"), ts.Minutes.ToString());
		}
	}

	void OpenOneButtonPopup(string title, string content)
	{
		Popup_OneButton popupSc = PopupManager.PushPopup(PopupKind.OneButton) as Popup_OneButton;
		popupSc.SetPopupWithTitleAndBody(title, content);
	}
}